package com.wms.controller;

import com.wms.bean.PageBean;
import com.wms.bean.ResultBean;
import com.wms.core.R;
import com.wms.service.ZhiJianService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "质检")
public class ZhiJianContorller {
    @Autowired
    ZhiJianService zhiJianService;
    @ApiOperation("到货质检")
    @GetMapping("/chaZJ")
    public PageBean chaZhiJian(int page, int pageSize){
        PageBean pageBean=zhiJianService.chaZhiJian(page,pageSize);
        return pageBean;
    }

    @PostMapping("/pingjia")
    @ApiOperation("评价")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "createBy",value = "评论人（质检员）",dataType = "String"),
            @ApiImplicitParam(name = "inspectId",value = "质检id",dataType = "int",required = true),
            @ApiImplicitParam(name = "content",value = "评论内容",dataType = "String",required = true)
    })
    public ResultBean pingjia(String createBy,int inspectId,String content){
        int n= zhiJianService.pingjia(createBy,inspectId,content);
        return R.success("增加评论",n);
    }

    @ApiOperation("采购质检 条件查询+分页")
    @GetMapping("/CGZJall")
    public PageBean queryDataWithPage( @RequestParam(required = false,value = "起始时间") String startTime,
                                       @RequestParam(required = false,value = "结束时间") String endTime,
                                       @RequestParam(required = false,value = "质检人") String inspectUser,
                                       @RequestParam(required = false,value = "供应商名称") String supplierName,
                                       @RequestParam(required = false,value = "采购单号") String purchaseId,
                                       @RequestParam(required = false,value = "物料名称") String materialName,
                                       @RequestParam(required = false,value = "物料编号") String materialCode,
                                       @RequestParam(required = false,value = "批次号") String batchNum,
                                       // 分页参数（默认值：第1页，每页10条）
                                       @RequestParam(defaultValue = "1") int pageNum,
                                       @RequestParam(defaultValue = "5") int pageSize){

        return zhiJianService.queryDataWithPage(startTime, endTime, inspectUser, supplierName, purchaseId,
                                                materialName, materialCode, batchNum, pageNum, pageSize);
    }
}
